﻿using System;
using FluentNHibernate.Mapping;

namespace Data.Model
{
    [Serializable]
    public class UserBase
    {
        public virtual int UserId { get; set; }
        public virtual string FirstName { get; set; }
        public virtual string LastName { get; set; }
        public virtual string Email { get; set; }
        public virtual string Adress { get; set; }
        public virtual int ProfilId { get; set; }

    }
    public class User : UserBase
    {
        public virtual Profil Profil { get; set; }
    }
    public class UserMap : ClassMap<User>
    {
        public UserMap()
        {
            Table("Users");
            Schema("dbo");
            Id(x => x.UserId).GeneratedBy.Assigned();
            OptimisticLock.Version();
            Map(x => x.FirstName).Length(50);
            Map(x => x.LastName).Length(50);
            Map(x => x.Email).Length(150);
            Map(x => x.Adress).Length(400);
            References(x => x.Profil).Class(typeof (Profil)).Not.Nullable().Column("ProfilId").Fetch.Select();
        }
    }
}
